package com.shopping_back.mapper;

import com.shopping_back.pojo.entity.SeckillItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.shopping_back.pojo.vo.SkuItemVO;
import com.shopping_back.pojo.vo.SkuVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 秒杀商品表 Mapper 接口
 * </p>
 *
 * @author Jack
 * @since 2025-07-12
 */
@Mapper
public interface SeckillItemMapper extends BaseMapper<SeckillItem> {

    @Select("SELECT s.id AS sku_id, s.spu_id, sp.title AS spu_title, s.specs_json, s.price, s.stock, s.sku_image, " +
            "fri.seckill_price, fri.seckill_stock, fri.limit_per_user, " +
            "NULL AS group_price, NULL AS required_count, NULL AS duration_minutes, " +
            "NULL AS threshold, NULL AS discount, NULL AS combo_price " +
            "FROM seckill_item fri " +
            "JOIN sku s ON fri.sku_id = s.id " +
            "JOIN spu sp ON s.spu_id = sp.id " +
            "WHERE fri.activity_id = #{activityId}")
    List<SkuItemVO> selectSeckillItems(Long activityId);
}
